<template>
  <div>
    <van-swipe
      class="my-swipe"
      :autoplay="3000"
      indicator-color="white"
      :show-indicators="false"
    >
      <van-swipe-item v-for="(item, index) in imgbanner" :key="index">
        <img :src="item.banner_img" alt="" />
      </van-swipe-item>
    </van-swipe>
    <div class="box2">
      <ul>
        <li>
          <img src="../assets/屏幕截图 2022-09-05 190007.jpg" alt="" />
          <p>特色课</p>
        </li>
        <li>
          <img src="../assets/屏幕截图 2022-09-05 190222.jpg" alt="" />
          <p>一对一辅导</p>
        </li>
        <li>
          <img src="../assets/屏幕截图 2022-09-05 190058.jpg" alt="" />
          <p>学习日历</p>
        </li>
      </ul>
    </div>
    <div class="card">
      <div class="card-item">
        <p>{{ list1.channel_info.name }}</p>
        <div class="box" v-for="(item, index) in list1.list" :key="index">
          <img :src="item.teacher_avatar" alt="" />
          <div>
            <h2>{{ item.teacher_name }}</h2>
            <b class="item">{{ item.introduction }}</b>
          </div>
        </div>
      </div>
    </div>
    <div class="card1">
      <div class="card-item">
        <p>{{ list2.channel_info.name }}</p>
        <div class="box" v-for="(item, index) in list2.list" :key="index">
          <h2>{{ item.title }}</h2>
          <b>共点击量</b>
          <img :src="item.cover_img" alt="" />
          <div>
            <b class="item">{{ item.id }}人报名</b>
            <b class="price"><van-icon name="points" />{{ item.price }}</b>
          </div>
        </div>
      </div>
    </div>
    <div class="card">
      <div class="card-item">
        <p>{{ list3.channel_info.name }}</p>
        <div class="box" v-for="(item, index) in list3.list" :key="index">
          <img :src="item.teacher_avatar" alt="" />
          <div>
            <h2>{{ item.teacher_name }}</h2>
            <b class="item">{{ item.introduction }}</b>
          </div>
        </div>
      </div>
    </div>
    <footer>
      <div class="footer-item">
        <span class="icon iconfont">&#xe69c;</span>
        <p>首页</p>
      </div>
      <div class="footer-item">
        <span class="icon iconfont">&#xe600;</span>
        <p>课程</p>
      </div>
      <div class="footer-item">
        <span class="icon iconfont">&#xe606;</span>
        <p>约课纪录</p>
      </div>
      <div class="footer-item">
        <span class="icon iconfont">&#xe623;</span>
        <p>练习</p>
      </div>
      <div class="footer-item">
        <span class="icon iconfont">&#xe654;</span>
        <p>我的</p>
      </div>
    </footer>
    <div class="envelope">
       <span class="icon iconfont">&#xe61b;</span>
    </div>
  </div>
</template>

<script>
import { banner, cartList } from "../request/http";
export default {
  data() {
    return {
      imgbanner: [],
      list1: [],
      list2: [],
      list3: [],
      list4: [],
    };
  },
  created() {
    this.banner();
  },
  methods: {
    banner() {
      banner().then((res) => {
        console.log(res);
        this.imgbanner = res.data;
      });
      cartList().then((res) => {
        console.log(res.data[0]);
        console.log(res.data[1]);
        console.log(res.data[2]);
        this.list1 = res.data[0];
        console.log(this.list1);
        this.list2 = res.data[1];
        this.list3 = res.data[2];
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 0px;
  text-align: center;
  background-color: #39a9ed;
  img {
    width: 100%;
    height: 100%;
  }
}
.box2 {
  background: rgb(242, 243, 245);
  ul {
    width: 90%;
    height: 2.747rem;
    margin: auto;
    position: relative;
    top: -0.667rem;
    margin-bottom: -0.533rem;
    list-style: none;
    display: flex;
    justify-content: space-between;
    li {
      width: 2.747rem;
      height: 2.747rem;
      background: #fff;
      border-radius: 10px;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
    }
  }
}
.card {
  background: rgb(242, 243, 245);
  p {
    border-left: 0.08rem solid red;
    padding-left: 0.267rem;
    font-size: 0.453rem;
  }
  .box {
    display: flex;
    width: 95%;
    margin: 0 auto;
    align-items: center;
    margin-bottom: 0.2rem;
    background: white;
    img {
      width: 1.067rem;
      height: 1.067rem;
      border-radius: 1.333rem;
      padding: 10px;
    }
    div {
      padding: 20px;

      .item {
        font-size: 0.32rem;
        color: #999;
      }
    }
  }
}
.card1 {
  background: rgb(242, 243, 245);
  p {
    border-left: 0.08rem solid red;
    padding-left: 0.267rem;
    font-size: 0.453rem;
  }
  .box {
    display: flex;
    width: 95%;
    margin: 0 auto;
    flex-direction: column;
    // align-items: center;
    margin-bottom: 0.2rem;
    background: white;
    h2 {
      font-size: 0.48rem;
    }
    b {
      font-size: 0.373rem;
    }
    img {
      width: 1.067rem;
      height: 1.067rem;
      border-radius: 1.333rem;
      padding: 10px;
    }
    div {
      padding: 20px;
      display: flex;
      justify-content: space-between;
      .item {
        font-size: 0.32rem;
        color: #999;
      }
      .price {
        color: #ff3c00;
      }
    }
  }
}
footer {
  display: flex;
  width: 100%;
  height: 1.333rem;
  bottom: 0px;
  background: white;
  position: fixed;
  justify-content: space-around;
  align-items: center;
  .footer-item {
    text-align: center;
    width: 20%;
    p {
      padding: 0;
      margin: 0;
    }
    &:hover {
      color: #ff3c00;
    }
  }
}
.envelope{
    background: #007aff;
    border-radius: 100%;
    text-align: center;
    line-height: 1.6rem;
    color: #fff;
    position: fixed;
    bottom: 2.133rem;
    right: .267rem;
    width: 1.6rem;
    height: 1.6rem;
    z-index: 99999999;
}
</style>